<?php

namespace app\common\model;

/**
 * [论坛表]
 * @author [C。]
 * @return html
 */
class Fgroup extends Base
{
    protected $name = 'fgroup';
    /**
     * 根据搜索条件获取列表信息
     */
    public function getByConditon($map, $from=0, $size = 5)
    {
        $order = ['f.id' => 'desc'];
        $join = [
            ['app_member am','am.id = f.memid'],
        ];
        $result =  $this->field('am.id memid,am.img,am.username,am.introduction,f.addr,f.content,f.imgs,f.addtime,f.id,am.identity,f.parid,f.touserid')
            ->alias('f')
            ->join($join)
            ->where($map)
            ->limit($from, $size)
            ->order($order)
            ->select();

        return $result;
    }

    /**
     * 根据条件来获取列表的数据的总数
     * @param array $param
     */
    public function getCountByCondition($map = []) {
        $order = ['f.id' => 'desc'];
        $join = [
            ['app_member am','am.id = f.memid'],
        ];
        $result =  $this
            ->alias('f')
            ->join($join)
            ->where($map)
            ->order($order)
            ->count();
        return $result;
    }
}